﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using ExtAspNet;
using Manager;
using Model;
using System.Data;
namespace HealthSystem
{
    public partial class MyAdmin : BasePage
    {
        HW_Manger_Admin_UserManager manager = new HW_Manger_Admin_UserManager();
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                BindGrid();
            }
        }
        public void BindGrid()
        {
            string DistrictId = CustomerProfile.DistrictId;
            int count = 0;
            DataTable list = manager.GetSubAdmin(Gird1.PageIndex, Gird1.PageSize, out count, DistrictId);
            Gird1.RecordCount = count;
            this.Gird1.DataSource = list;
            this.Gird1.DataBind();
        }
        public void Grid1_DoubleClick(object sender, ExtAspNet.GridRowClickEventArgs e)
        {
            int index = e.RowIndex;
            string pid = this.Gird1.Rows[index].DataKeys[1].ToString();
            PageContext.RegisterStartupScript(Window1.GetShowReference("SubAdmin.aspx?pid=" + pid, "区县镇管理员"));
        }
        public void Window1_Close(object sender, EventArgs e)
        {

        }
        public void PageIndexChange(object sender, ExtAspNet.GridPageEventArgs e)
        {
            Gird1.PageIndex = e.NewPageIndex;
            try
            {
                if (actionbt.Text == "search")
                {
                    Search(searchbox.Text.Trim());
                }
                else
                {
                    BindGrid();
                }
            }
            catch
            {
                Alert.Show("数据错误");
            }
        }
        public void SearchClick(object sender, EventArgs e)
        {
            try
            {
                Search(searchbox.Text.Trim());
            }
            catch
            {
                Alert.Show("查询错误");
            }
        }
        public void Search(string searchString)
        {
        //    string DistrictId = CustomerProfile.DistrictId;
        //    int count = 0;
        //    DataTable list = manager.Search(Gird1.PageIndex, Gird1.PageSize, out count, DistrictId, searchString);
        //    Gird1.RecordCount = count;
        //    this.Gird1.DataSource = list;
        //    this.Gird1.DataBind();
        //    this.actionbt.Text = "search";
        }
    }
}